package com.cait.dutyfree.action.impl;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.apache.struts2.util.ServletContextAware;

import com.cait.dutyfree.dataaccess.AirlineServiceDao;
import com.cait.dutyfree.pojo.Airline;
import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionSupport;

public class AirlineAction extends ActionSupport implements
		ServletContextAware, SessionAware, ServletRequestAware {
	private static final long serialVersionUID = 1L;

	// struts specific settings
	private ServletContext servletContext;
	private HttpServletRequest request;
	private Map<String, Object> session;

	// spring injection
	private AirlineServiceDao airlineServiceDao;

	// form beans automatically set by struts 2
	private List<Airline> airlines = new ArrayList<Airline>();

	@Override
	public void setServletRequest(HttpServletRequest arg0) {
		this.request = arg0;
	}

	@Override
	public void setSession(Map<String, Object> arg0) {
		this.session = arg0;
	}

	@Override
	public void setServletContext(ServletContext arg0) {
		this.servletContext = arg0;
	}

	public void setAirlineServiceDao(AirlineServiceDao airlineServiceDao) {
		this.airlineServiceDao = airlineServiceDao;
	}

	// form beans getter & setters
	public List<Airline> getAirlines() {
		return airlines;
	}

	public String airlines() {
		this.airlines = airlineServiceDao.getAll();

		return Action.SUCCESS;
	}

}
